<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page session="true" %>
<%@ page import="javax.portlet.*" %>
<%@page import ="rai.dto.*" %>
<%@page import ="rai.dao.*" %>
<%@page import = "java.util.*" %>

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<portlet:defineObjects/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Personal Information Tracking System</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<script type="text/javascript" src='<%= request.getContextPath() + "/js/calendarDateInput.js" %>'></script>
<script type="text/javascript">
    function getForm(namespace, name) {
        return document.forms[namespace + name];
    }
    function back_to_emp_info_form(namespace, name) {
        var frm = getForm(namespace, name);
        frm.txtAction.value = "back_to_empInfo_form_2";
        frm.submit();
    }
    function back_to_login(namespace, name) {
		var frm = getForm(namespace, name);
		frm.txtAction.value = "back_to_login_form";
		frm.submit();
	}
    function edit_profile(namespace, name){
		var frm = getForm(namespace , name);
		frm.txtAction.value = "edit_profile";
		frm.submit();
	}
    function edit_acc(namespace, name, empID, empName){
		var frm = getForm(namespace , name);
		frm.txtEmpID.value = empID;
		frm.txtEmpName.value = empName;
		frm.txtAction.value = "access_edit_acc";
		frm.submit();
	}
    function add_acc(namespace, name){
		var frm = getForm(namespace , name);
		frm.txtAction.value = "access_add_acc";
		frm.submit();
	}
    function delete_acc(namespace, name){
		var frm = getForm(namespace , name);
		frm.txtAction.value = "del_acc";
		frm.submit();
	}
	
</script>
<link href='<%=request.getContextPath() + "/css/style.css" %>' rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<form name="<portlet:namespace/>adminManAcc" action="<portlet:actionURL/>" method="POST">
<input type="hidden" name="txtAction"></input>
<input type="hidden" name="txtEmpID"></input>
<input type="hidden" name="txtEmpName"></input>
<table>
	
	<tr class="title">
	
			<td colspan="2">		
					<h1><a href="#">Personal information tracking system </a></h1>
					<p>exploit the value of data</p>
					<hr />

			</td>
	</tr>
	<tr>
			<td colspan="2" align="left"> Welcome, <font color="orange"/><b>[${sessionScope.role}]${sessionScope.name}</b></font>
		| <a href="#">Home</a>
		| <a href="#" onclick="edit_profile('<portlet:namespace/>','adminManAcc')">Edit Profile</a>
		| <a href="#" onclick="back_to_login('<portlet:namespace/>','adminManAcc')">Logout</a>
			
	   </td>
	</tr>
	<tr>	
		<td>
			<table border="1">
				<tr>
					<td><h2 class="title">Accounts Information</h2></td>

				</tr>
				<tr>
					<td><p><em>Account List </em></p></td>
				</tr>	
				<tr>
					<td>
						<table border="1" width="100%">
							<tr>
								<td align="center" valign="middle">Check</td>								
								<td align="center" valign="middle">EmpID</td>
								<td align="center" valign="middle">UserName</td>
								<td align="center" valign="middle">Employee Name</td>
								<td align="center" valign="middle">Role</td>
								<td align="center" valign="middle">Last Login</td>
								<td align="center" valign="middle"><div align="center">Action</div></td>
								
							</tr>
							
								<%AdminActionDAO adminDAO = new AdminActionDAO();
								  List<UserDataDTO> listAcc = adminDAO.getAccList();
								  for (int i = 0; i < listAcc.size(); i++) {
								      UserDataDTO temp = listAcc.get(i);
								%>
								<tr>
									<td><label>
									<input type="checkbox" name="chkEmp" value="<%=temp.getEmpID() %>" />
								</label></td>
									<td align="center" valign="middle"><%=temp.getEmpID() %></td>
									<td align="center" valign="middle"><%=temp.getUsername() %></td>
									<td align="center" valign="middle"><%=temp.getEmpName() %></td>
									<td align="center" valign="middle"><%=temp.getRole() %></td>
									<td align="center" valign="middle"><%=temp.getLastlogin() %></td>
									
									<td align="center" valign="middle"><a href="#" onclick="edit_acc('<portlet:namespace/>','adminManAcc','<%=temp.getEmpID()%>','<%=temp.getEmpName() %>')">Edit</a></td>
									
								</tr>
								<%} %>
					
						</table>
					</td>
					
				</tr>
							<tr>
					<td>
					<input name="" type="button" value="Add" onclick="add_acc('<portlet:namespace/>','adminManAcc')"/>
					<input name="" type="button" value="Delete" onclick="delete_acc('<portlet:namespace/>','adminManAcc')"/>
					</td>
					</tr>
				
				
			</table>			
		</td>

	</tr>
	<tr>
		<td colspan="2">
			<div style="clear: both;">&nbsp;</div>
			<div id="footer"><p>Development by HCMUT-Group3.</p>
			</div>
		</td>
	</tr>
</table>
</form>
</body>
</html>
